{{ define "title" -}}
{{ if eq .Data.Singular "author" -}}
  {{- $author := (index (.Site.Data.authors | default dict) .Title) -}}
  {{- $author_lang := (index ($author | default dict) .Site.Language.Lang) -}}
  {{- $author_name := $author_lang.name.display | default $author.name.display | default .Title -}}
  {{ $author_name }} · {{ .Site.Title }}
{{- else -}}
  {{ .Title }} · {{ .Site.Title }}
{{- end }}
{{- end }}

{{ define "content"}}
{{ $paginator := .Paginate (where .Data.Pages.ByDate.Reverse "Type" "post") (index .Site.Params "archive-paginate" | default 10) }}
<section id="archive" class="archive">
  {{ if not $paginator.HasPrev }}
    {{ if eq .Data.Plural "tags" }}
      <div class="archive-title tag">
        <h2 class="archive-name">{{ i18n "tag" }}{{ .Title }}</h2>
      </div>
    {{ else if eq .Data.Plural "categories" }}
      <div class="archive-title category">
        <h2 class="archive-name">{{ i18n "category" }}{{ .Title }}</h2>
      </div>
    {{ else if eq .Data.Singular "author" }}
      {{- $author := (index (.Site.Data.authors | default dict) .Title) -}}
      {{- $author_lang := (index ($author | default dict) .Site.Language.Lang) -}}
      {{- $author_name := $author_lang.name.display | default $author.name.display | default .Title -}}
      <div class="archive-title author">
        <h2 class="archive-name">{{ i18n "author_item" }}{{ $author_name }}</h2>
      </div>
    {{ end }}
  {{ end }}

  {{ range $paginator.Pages }}
    <div class="archive-post">
      <time datetime="{{ .Date.Format "2006-01-02" }}" class="archive-post-time">
        {{ .Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}
      </time>
      <span class="archive-post-title">
        <a href="{{ .RelPermalink }}" class="archive-post-link">
          {{ .Title }}
        </a>
      </span>
    </div>
  {{ end }}
</section>

<!-- pagination -->
{{ partial "pagination.html" . }}

{{ end }}
